package lambda

import (
	"errors"
	"fmt"
)

func read() error {
	var errO error
	f := func(a, b int) {
		result, err := divided(a, b)
		if err == nil {
			fmt.Println("current number:", result)
		} else {
			fmt.Println("error:", err.Error())
			errO = err
			return
		}
	}

	f(1, 1)
	f(1, 0)
	f(7, 1)
	f(5, 1)
	f(6, 1)
	return errO
}

func divided(a, b int) (int, error) {
	if b == 0 {
		return 0, errors.New("not zero")
	}
	return a / b, nil
}
